﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;

namespace MWTWorkUnitMgmtTool.DataAccess.TableGatewayRepository
{
    public class WarehouseLocationRepository:IWarehouseLocationRepository
    {
        private ITableGatewayRepository _tableGatewayRepository;
        string _connectionString; 

        public WarehouseLocationRepository(ITableGatewayRepository tableGatewayRepository)
        {
           _tableGatewayRepository = tableGatewayRepository;
           _connectionString = ConfigurationManager.AppSettings["DB_SAPB1Gateway"].ToString(); 
        }

        #region IWarehouseLocationRepository Members

        public IEnumerable<System.Data.IDataRecord> GetWarehouseLocationByLocationCode(string locationCode)
        {
            return _tableGatewayRepository.Retrieve("SELECT * FROM tblWarehouseLocations WHERE LocationCode = @LocationCode", _connectionString, delegate(SqlParameterCollection p)
            {
                p.Add("@LocationCode", System.Data.SqlDbType.VarChar).Value = locationCode;
            });
        }

        #endregion
    }
}
